import 'dart:async';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_learn_vi/src/bean/bean_video.dart';
import 'package:flutter_learn_vi/src/page/study/course/video_details2_widget.dart';

import '../../../bean/bean_integral.dart';
import '../../../bean/bean_train.dart';
import '../../../bean/bean_user_account.dart';

/// 创建人： Created by zhaolong
/// 创建时间：Created by  on 2021/1/13.
///
/// 可关注公众号：我的大前端生涯   获取最新技术分享
/// 可关注网易云课堂：https://study.163.com/instructor/1021406098.htm
/// 可关注博客：https://blog.csdn.net/zl18603543572
///
/// 代码清单
///横屏
class VideoDetailsScreenFullWidget extends StatefulWidget {
  final StreamController streamController;

  final bool isFullScreen;
  final VideoModel init;

  final Duration currentDuration;

  ///积分配置
  final IntegralStatBean integralStatBean;

  final TaskBean taskBean;

  ///培训入口进入
  final int trainId;
  final TrainBean trainBean;
  VideoDetailsScreenFullWidget({
    this.streamController,
    this.isFullScreen = false,
    this.integralStatBean,
    this.taskBean,
    this.init,
    this.currentDuration,
    this.trainBean,
    this.trainId,
  });

  @override
  _VideoDetailsScreenFullWidgetState createState() =>
      _VideoDetailsScreenFullWidgetState();
}

class _VideoDetailsScreenFullWidgetState
    extends State<VideoDetailsScreenFullWidget> {
  @override
  void initState() {
    super.initState();
    if (widget.isFullScreen) {
      SystemChrome.setEnabledSystemUIOverlays([]); //隐藏状态栏，底部按钮栏
      SystemChrome.setPreferredOrientations(
          [DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]);
    }
  }

  @override
  void dispose() {
    super.dispose();
    if (widget.isFullScreen) {
      SystemChrome.setPreferredOrientations(
          [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);
      SystemChrome.setEnabledSystemUIOverlays(
          SystemUiOverlay.values); //显示状态栏、底部按钮栏

    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      ///填充布局
      body: VideoDetailsWidget(
        isFullScreen: widget.isFullScreen,
        integralStatBean: widget.integralStatBean,
        taskBean: widget.taskBean,
        isShowBack: true,
        currentDuration: widget.currentDuration,
        init: widget.init,
        trainBean: widget.trainBean,
        trainId: widget.trainId,
      ),
    );
  }
}
